import 'package:word_game/engine/core.dart';
import 'task.dart';
import '../material/empty_bucket.dart';
import 'taskable_hero.dart';

class AbortEvent extends Eventable {
  AbortEvent() : super('放弃');

  @override
  void doEvent(owner) {
    var task = owner as Task;
    var hero = World.instance.hero as TaskableHero;
    task.owner.taskStates.remove('${task.code}_${hero.name}');
    hero.tasks.removeWhere((item)=>item.code==task.code);
    hero.pureRemoveThing(EmptyBucket('1'));
    Engine.instance.displayer.displayString('[${hero.name}]放弃了任务[${task.name}]。');
  }
}